var jcrop_api;
		
		function initCutImg(){
			$theimg = $("#target");
			if(jcrop_api){
				jcrop_api.setImage($theimg.attr("src"));
			}
			$("#ErrorMessage").text("");
			cropObj = $('#target').Jcrop({
				aspectRatio:"1",
				bgColor:"white",
				minSize:[30,30],
				onChange:updatePreview,
				onSelect:updatePreview,
				boxWidth:'300',
				boxHeight:'300',
				onRelease:cleanData,
				setSelect:[0,0,100,100]
			},function(){
				jcrop_api = this;
			});
			function updatePreview(c){
				//设置值
				if (parseInt(c.w) > 0)
				{
					$("#saveBtn").removeAttr("disabled");
					$("#headX").val(c.x);
					$("#headY").val(c.y);
					$("#headWidth").val(c.w);
					$("#headHeight").val(c.h);
				}
			};
			function cleanData(){
				$("#saveBtn").attr("disabled","disabled");
			};
		}
		function saveImage(o){
			$(o).attr("disabled", "disabled");
			var headX = $("#headX").val();
			var headY=$("#headY").val();
			var headWidth=$("#headWidth").val();
			var headHeight=$("#headHeight").val();
			var LastheadImg= $("#LastheadImg").val();
			var isCutImg="true";
			if(headWidth<30||headHeight<30){
				$("#ErrorMessage").text("请重新传图片!");
				return false;
			}
			if(LastheadImg==""){
				$("#ErrorMessage").text("请上传头像图片");
				return false;
			}
			$("#ErrorMessage").text("请稍等。。。");
			//提交使用Ajax提交表单
			$.ajax({
				type : "post",
				url : basepath+"/UserPicUpload",
				data : {
						"picX":headX,
						"picY":headY,
						"picWidth":headWidth,
						"picHeight":headHeight,
						"isCutImg":"true",
						"LastheadImg":LastheadImg
						}, 
				success : function(result) {
							if(result==""){
								alert("修改失败");
							}else{
								var upFileName="";
		                        var path="";
		                        var showpath="";
		                        var jsonObj = eval('('+result+')');  //解析后台返回的数据
		                        for(var o in jsonObj){
		                        	upFileName=jsonObj[o].upFileName;
		                        	path=jsonObj[o].path;
		                        	showpath=jsonObj[o].accessPath;
		      					}
		                        $("#LastheadImg").val(path+"\2"+upFileName+"\2"+showpath); ///设置值给这个隐藏域
								$("#saveBtn").removeAttr("disabled");
								$("#target").attr("src",showpath);
								//更换页面的的图片
								if(jcrop_api){
									jcrop_api.setImage(showpath);
								}
					        }
							$("#ErrorMessage").text("");
						},
				error : function(XMLHttpRequest, textStatus, errorThrown){
							$("#ErrorMessage").text("请求错误"+textStatus);
						}
				});
		}